export default function (res) {
  const blob = new Blob([res.data]);
  let disposition = decodeURI(res.headers['content-disposition']);
  // 从响应头中获取文件名称
  console.log(disposition,'disposition')
  let fileName = disposition.substring(disposition.indexOf('fileName=') + 22, disposition.length);
  let text = fileName;
  if ('download' in document.createElement('a')) {
    // 非IE下载
    const elink = document.createElement('a');
    elink.download = text.substring(0, text.length - 1);
    elink.style.display = 'none';
    elink.href = URL.createObjectURL(blob);
    document.body.appendChild(elink);
    console.log(elink);
    elink.click();
    URL.revokeObjectURL(elink.href); // 释放URL 对象
    document.body.removeChild(elink);
  } else {
    // IE10+下载
    navigator.msSaveBlob(blob, fileName);
  }
}
